require(['../config/requireconfig'],function(config){
	//根据需要添加
	require(['zepto','common/mcommon','common/autocomplete','swiper','common/prodFeedBack',],function($,com,autocomplete,swiper,feedBack){
		
		com.init();
		feedBack.init();
		var pageLogic = new PageLogic($,com,swiper);
		pageLogic.init();
		
	})
});
var PageLogic = function($,com,Swiper){
	return{
		init:function(){
			var _this = this;
			$(".header-top").find(".menu").on("click",function(){
				$(".proposal-box").css("visibility","hidden");
			});
			_this.loadParts();
		},
		loadParts:function(){
			var _this = this;
			com.ajax({
				url:"/queryPartNumberList.json",
				success:function(res){
					var proposals =[];
					$(res).each(function(idx,obj){
						if(obj){
							proposals[idx]=obj;	
						}
					})
					_this.enableTypeHead(proposals);
				}
			});
		},
		enableTypeHead:function(assets){
			var _this = this;
			var allSize =   window.lib.flexible.rem2px(6.6);
			var btnSize =  window.lib.flexible.rem2px(1.6);
			$('#search-form').autocomplete({
                hints: assets,
                width: allSize,
                height:  window.lib.flexible.rem2px(0.5),
                btnwidth:btnSize,
                buttonText:'查询',
                mustMatch: true,
                onSubmit: function(text){
	            	_this.loadRes(text);
		        }
		    });
		},
		loadRes:function(text){
			var _this = this;
			com.ajax({
				url:'/getByVehicleNo.json',
				data:{vehicleNo:text},
				success:function(res){
					if(res.data.desList.length == 0){
						alert("没有该零件号信息");
						return;
					}
					_this.genRes(res.data,text);
				}
			});
		},
		genRes:function(data,text){
			var _this = this;
			var html = "";
			html += '<div class="prd-info">';
			html += '	<div class="swiper-container prdRmkSwiper"> ';
			html += '		<div class="swiper-wrapper" id="pics"> ';
			$(data.desList1).each(function(idx,img){
				html += '		<div class="swiper-slide"> ';
				html += '          <div class="img-con">';
				html += '			 <img src="' + (com.Config.domain + data.lj + img.reserve5) + '" /> ';
				html += '		   </div> ';
				html += '		</div> ';
			});
			html += '		</div> ';
			html += '	</div> ';
			html += ' <div class="prd-rmk1"> ';
			html += '	<ul class="prd-rmk" tg="' + text + '"> ';
			html += '		<li><span class="left">零件号：</span><span>' + data.desList[0].reserve2 + '</span></li> ';
			html += '		<li><span class="left">德科号：</span><span>' + data.desList[0].reserve3 + '</span></li> ';
			html += '		<li><span class="left">零件名称：</span><span>' + data.desList[0].reserve1 + '</span></li> ';
			html += '		<li><span class="left">产品系列</span><span>' + data.desList[0].reserve4 + '</span></li> ';
			html += '	</ul> ';
			html += '	<div class="part-prompt"><span>点击查看更多详细内容</span></div> ';
			html += ' </div> ';
			html += '</div>';
			$(".search-res").html(html);
			var swiper = new Swiper('.prdRmkSwiper', {
				lazy: true
		    });
		    $(".prd-rmk1").on("click",function(){
		    	com.utils().windowJump("partDet.htm?vehicleNo=" + $(".prd-rmk").attr("tg"));
		    })
		},
		bindEvent:function(){
			var _this = this;

		}
	}
}